Repository navigation
Feature/system collectors - #2117
Open
harryzhang-wq wants to merge 4 commits into
Open
harryzhang-wq wants to merge 4 commits into
harryzhang-wq wants to merge 4 commits into
Conversation
harryzhang-wq
force-pushed
the
feature/system-collectors
branch
from
July 3, 2026 12:43
fbb0d11 to
28da754
Compare
harryzhang-wq
force-pushed
the
feature/system-collectors
branch
from
July 3, 2026 13:00
28da754 to
a27811b
Compare
There was a problem hiding this comment.
Pull request overview
Extends the Inventory Collector framework by adding a postStart “collector” hook that emits startup inventory events enriched with container-scoped resource limits (cgroup CPU/memory) and filesystem capacity, rather than host-level resources.
Changes:
- Add a collector CLI subcommand (
lifecycle postStart collector) and wire it into member container postStart lifecycle when a hiddencollectorfeature flag is enabled. - Introduce a small collector framework (
pkg/collect) plus Linux-only system collectors (cgroup limits, filesystem stats) and supporting tests. - Add a generic concurrent aggregation utility (
pkg/util/collector.go) used to fan-in metrics from multiple collectors.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new collector logger in --log.level help output. |
| pkg/util/shutdown/shutdown.go | Adds process-stable BootID/BootTime helpers used to tag collector events. |
| pkg/util/k8sutil/lifecycle.go | Adds helper to build the postStart exec handler for running the collector. |
| pkg/util/collector.go | New generic concurrent aggregation utility used by collectors. |
| pkg/util/collector_test.go | Unit tests for the new generic util collector. |
| pkg/deployment/resources/pod_creator_gateway_container.go | Enables collector postStart hook for gateway container when feature flag is enabled. |
| pkg/deployment/resources/pod_creator_arangod.go | Enables collector postStart hook for arangod container when feature flag is enabled. |
| pkg/deployment/features/collector.go | Adds hidden collector feature flag definition. |
| pkg/collect/logger.go | Adds a dedicated collector logger. |
| pkg/collect/collector.go | Implements a registry that runs all metric collectors and aggregates their output. |
| pkg/collect/collector_resource_other.go | Non-Linux build stub for host resource collector. |
| pkg/collect/collector_resource_linux.go | Linux host resource collector (CPU count + /proc/meminfo total). |
| pkg/collect/collector_resource_linux_test.go | Tests for the Linux host resource collector. |
| pkg/collect/collector_filesystem_test.go | Tests for filesystem collector behavior. |
| pkg/collect/collector_filesystem_other.go | Non-Linux build stub for filesystem collector. |
| pkg/collect/collector_filesystem_linux.go | Linux filesystem collector using unix.Statfs. |
| pkg/collect/collector_cgroup_test.go | Tests for cgroup v1/v2 limit parsing and “unlimited/absent” behavior. |
| pkg/collect/collector_cgroup_other.go | Non-Linux build stub for cgroup collector. |
| pkg/collect/collector_cgroup_linux.go | Linux cgroup collector reporting CPU/memory limits (v1 + v2). |
| pkg/collect/collect.go | Implements the postStart collector loop and event emission to stdout. |
| pkg/collect/collect_test.go | Tests for registry collection and event construction. |
| docs/cli/arangodb_operator.md | Documents the new collector logger in CLI docs. |
| cmd/lifecycle_post_start.go | Adds the hidden lifecycle postStart collector command and flags. |
| CHANGELOG.md | Adds a changelog entry for the Inventory Collector feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+63
to
+64
| // NewCollector creates a Collector. A background goroutine drains pushed items until Done is called, | ||
| // so Push never blocks and is safe to call concurrently. |
Contributor
Author
There was a problem hiding this comment.
This file is Adam's #2115 framework - not my collectors. need to confirm with Adam
Comment on lines
+80
to
+100
| func (c *collector[T]) Collect() ([]T, error) { | ||
| c.lock.Lock() | ||
| defer c.lock.Unlock() | ||
|
|
||
| out := util.NewCollector[T]() | ||
|
|
||
| for _, e := range c.collectors { | ||
| e := e | ||
| if err := out.Run(func(p util.Pusher[T]) error { | ||
| return e.CollectEvents(p) | ||
| }); err != nil { | ||
| return nil, err | ||
| } | ||
| } | ||
|
|
||
| if err := out.Done(); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return out.Collect(), nil | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This file is Adam's #2115 framework - not my collectors. need to confirm with Adam
jwierzbo
approved these changes
Jul 6, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the Inventory Collector framework (#2115) with system collectors that
report the container's actual resource allocation, so startup events carry real
per-container resource inventory instead of an empty body.
Motivation
The existing
resourceCollectorreports host-level values (runtime.NumCPU()and
/proc/meminfo). Inside a container these over-report — they reflect thenode, not the cgroup limit the customer was allocated. To measure real usage
(and detect contract breaches) we need the cgroup-enforced limits.
Changes
Two new collectors, each implementing
ECollector[Metric]and self-registeringvia
init()— additive, the existingresourceCollectoris untouched:collector_cgroup.gosystem_cpu_limit,system_memory_limitcpu.cfs_quota_us/cpu.cfs_period_us,memory.limit_in_bytes) and v2 (cpu.max,memory.max); v2 detected viacgroup.controllerscollector_filesystem.gosystem_fs_total,system_fs_freeunix.Statfsunder a configurable path (default/)Unlimited limits or absent cgroup files are treated as "nothing to push" (not an
error), so the collector is safe outside a container.